﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace EEDS.Core
{
    public sealed class HsbPaletteConverter : RelationshipPaletteConverter
    {
        public override int ColourRelationship(Color colourA, Color colourB)
        {
            int temp;
            int relationship;

            temp = (int)(colourA.GetHue() - colourB.GetHue());
            if (temp < 0)
                temp = -temp;
            relationship = temp;

            temp = (int)(colourA.GetSaturation() * 360 - colourB.GetSaturation() * 360);
            if (temp < 0)
                temp = -temp;
            relationship += temp;

            temp = (int)(colourA.GetBrightness() * 360 - colourB.GetBrightness() * 360);
            if (temp < 0)
                temp = -temp;
            relationship += temp;

            return relationship;
        }

        private HsbPaletteConverter() { }
        public static readonly HsbPaletteConverter Instance = new HsbPaletteConverter();
    }
}
